﻿#include "buttongroup_1.h"
#include "ui_buttongroup_1.h"

ButtonGroup_1::ButtonGroup_1(QWidget* parent) : QWidget(parent), ui(new Ui::ButtonGroup_1Class) {
	ui->setupUi(this);
}

ButtonGroup_1::~ButtonGroup_1() { delete ui; }

void ButtonGroup_1::initButtons() {
	// 设置按钮的大小
	QVector<QPushButton*> btns;
	btns << ui->start << ui->playCard << ui->playCard1 << ui->pass << ui->addButton
		<< ui->onePerson << ui->twoPerson << ui->threePerson << ui->fourPerson;
	for (int i = 0; i < btns.size(); ++i) {
		btns[i]->setFixedSize(60, 35);
	}
	ui->textEdit->setFixedSize(60, 25);


	// 按钮点下，槽函数都是发射信号
	connect(ui->onePerson, &QPushButton::clicked, this, [=]() { emit num_players(1); });
	connect(ui->twoPerson, &QPushButton::clicked, this, [=]() { emit num_players(2); });
	connect(ui->threePerson, &QPushButton::clicked, this, [=]() { emit num_players(3); });
	connect(ui->fourPerson, &QPushButton::clicked, this, [=]() { emit num_players(4); });

	// 发出启动游戏的信号
	connect(ui->start, &QPushButton::clicked, this, [=]() { emit startGame(); });
}

//选择显示的按钮组，包括type所包含的5个按钮组
void ButtonGroup_1::selectPanel(Panel type) {
	ui->stackedWidget->setCurrentIndex(type);
}
